package com.xh.blog.user.service.impl;

import com.xh.blog.user.dao.UserInfoMapper;
import com.xh.blog.user.entity.UserInfoEntity;
import com.xh.blog.user.model.dto.UserInfoDto;
import com.xh.blog.user.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by xieha on 2019-11-21.
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserInfoMapper userInfoMapper;
    public Long insertUser(UserInfoDto user){
        UserInfoEntity userInfo = new UserInfoEntity();
        BeanUtils.copyProperties(user,userInfo);
        userInfoMapper.insert(userInfo);
        return userInfo.getId();
    }
    public UserInfoDto getUser(Long userId){
        UserInfoEntity userInfo = userInfoMapper.selectById(userId);
        UserInfoDto userInfoDto = new UserInfoDto();
        BeanUtils.copyProperties(userInfo,userInfoDto);
        return userInfoDto;
    }
}
